package org.example.com.Controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.annotation.Resource;

import org.example.com.Bean.Book;
import org.example.com.service.Bookservice;
import org.example.com.util.JsonResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/book")
public class BookController {
    @Resource
    private Bookservice bookService;
    @GetMapping("/fresh")
    public JsonResult findFreshBook()
    {

        return bookService.findFreshBook();
    }
    @GetMapping("/a")
    @Operation(description = "返回图书信息",responses = {
            @ApiResponse(description = "返回结果")
    })
    public Book a(){
        return new Book();
    }
    @GetMapping("/lower")
    public JsonResult findLowerBook(){

        return bookService.findLowerBook();
    }
    @GetMapping("/b")
    @Operation(description = "返回图书信息",responses = {
            @ApiResponse(description = "返回结果")
    })
    public Book b(){
        return new Book();
    }
    @GetMapping("/fresh_more/{page}")
    public JsonResult findFreshBookMore(@PathVariable("page")int page){
        return bookService.findFreshBookmore(page);
    }
    @GetMapping("/lower_more/{page}")
    public JsonResult findLowerBookMore(@PathVariable("page")int page){
        return bookService.findLowerBookmore(page);
    }
    @GetMapping("/search_book/{name}/{page}")
    public JsonResult findSearchbookName(@PathVariable("name")String name,@PathVariable("page") int page){
        return bookService.findSearchByBookName(name,page);
    }
    @GetMapping("/category/{id}/{page}")
    public JsonResult findCategorybook(@PathVariable("id")String categoryId,@PathVariable("page") int page){
        return bookService.findCategoryBook(categoryId,page);
    }

}
